package com.solace.selenium.controller;

import com.solace.selenium.entity.Authorization;
import com.solace.selenium.entity.JsonResult;
import com.solace.selenium.service.AuthorizationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("key")
public class KeyController {
    @Autowired
    private AuthorizationService authorizationService;

    /**
     * 作者 CG
     * 时间 2021/8/22 11:55
     * 描述  获取机器码
     */
    @RequestMapping(value = "getLocalKeyAndSave")
    public JsonResult getLocalKeyAndSave() {
        String localKeyAndSave = authorizationService.getLocalKeyAndSave();
        return new JsonResult(localKeyAndSave);
    }
    /**
      *
      * 作者 CG
      * 时间 2021/8/22 11:56
      * 描述  获取激活码信息
      */

    @RequestMapping(value = "getWebInterceptor")
    public JsonResult getWebInterceptor() {
        Authorization webInterceptor = authorizationService.getWebInterceptor();
        return new JsonResult(webInterceptor);
    }
    /**
      *
      * 作者 CG
      * 时间 2021/8/22 12:13
      * 描述  激活
      */
    @RequestMapping(value = "decryptionKey")
    public JsonResult decryptionKey(String key) {
         authorizationService.decryptionKey(key);
        return new JsonResult("OK");
    }
    /**
      *
      * 作者 CG
      * 时间 2021/8/22 15:49
      * 描述  删除授权码
      */
    @RequestMapping(value = "deleteAuthCode")
    public JsonResult deleteAuthCode() {
        authorizationService.deleteAuthCode();
        return new JsonResult("OK");
    }
}
